﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SCGILite.SCgi;
using SCGILite.NetLib;
using SCGILite.Helper;
using System.IO;
using System.Globalization;

namespace HelloWorld
{
    class SimpleSCGISession: SCgiSession
    {
        public SimpleSCGISession(ISocketSession tcp)
            : base(tcp)
        {
        }

        public override void OnSCgiBodyReady()
        {
            byte[] buf = Encoding.UTF8.GetBytes("hello world SCGILite!!\r\n i'm youkebing!!");
            MemoryStream ms = new MemoryStream(buf);
            ms.Position = 0; 
            Dictionary<string, string> headers = new Dictionary<string, string>();
            headers["Content-Type"] = "text/html; charset=utf-8";
            headers["Server"] = "YxjWeb/1.0.11";
            headers["Content-Length"] = ms.Length.ToString();
            this.ResponseHeaders(headers);
            this.ResponseBody(new NetOutputStream(ms));
            this.EndResponse();
        }
    }
}
